package org.leumasjaffe.initiativeTracker.operator;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.leumasjaffe.initiativeTracker.distributed.controller.DownloadHandler;

import edu.wpi.heineman.xml.Message;


/**
 * Imports and updates Character array
 * @author Sam Jaffe
 *
 */
@NonNullByDefault
public abstract class CharacterImporter {

	public static void importTracker(String id) {
		String output = "";
		File f = new File(id + ".initiative");
		if (!f.exists()) return;
		try (FileInputStream fis = new FileInputStream(f);
				DataInputStream dis = new DataInputStream(fis);
				BufferedReader br = new BufferedReader(new InputStreamReader(dis))) {
			String strLine = "";
			while ((strLine = br.readLine()) != null)
				output += strLine;
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println(id);
		new DownloadHandler().process(new Message(output)); /**/
	}

}
